package view;

import lib.EvenlySpacedHorizontalFieldManager;
import lib.Icon;
import lib.classes.TitleBar;
import lib.gui.ProfileScreen;
import lib.gui.ScreenTemplate;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.component.NullField;
import net.rim.device.api.ui.container.GridFieldManager;

public class Home extends ScreenTemplate implements FieldChangeListener
{

	private Icon profile, photos, friends, browse, requests, settings;
	public Home() 
	{
		super("Home", true);
		
		EvenlySpacedHorizontalFieldManager row1 = new EvenlySpacedHorizontalFieldManager(Field.USE_ALL_WIDTH);
		
		profile = new Icon("Profile", Bitmap.getBitmapResource("img/icons/profileM.png"));
		profile.setChangeListener(this);
		
		friends = new Icon("Friends", Bitmap.getBitmapResource("img/icons/friends2.png"));
		
		photos = new Icon("Photos", Bitmap.getBitmapResource("img/icons/photos.png"));
		requests = new Icon("Requests", Bitmap.getBitmapResource("img/icons/photos.png"));
		browse = new Icon("Browse", Bitmap.getBitmapResource("img/icons/browse.png"));
		settings = new Icon("Settings", Bitmap.getBitmapResource("img/icons/settings2.png"));
		
		row1.add(profile);
		row1.add(friends);
		row1.add(photos);
		add(row1);
		row1.setMargin(new XYEdges(100, 0,10,0) );
		
		EvenlySpacedHorizontalFieldManager row2 = new EvenlySpacedHorizontalFieldManager(USE_ALL_WIDTH);

		row2.add(browse);
		row2.add(requests);
		row2.add(settings);
		row2.setPadding(new XYEdges(5, 0, 0, 0));
		add(row2);
		profile.setClickListener(this);
		photos.setChangeListener(this);friends.setChangeListener(this);
		requests.setChangeListener(this);browse.setChangeListener(this);settings.setChangeListener(this);
		
		TitleBar title = new TitleBar(new NullField(), "Mingle", new NullField());
		setTitle(title);
		
	}
	public void fieldChanged(Field field, int context) 
	{
		if(profile.isFocus())
		{
			pushScreen(new ProfileScreen(ScreenTemplate.profile));
		}
	}

}
